Skip to content

Conversation

@ben-kaufman
Copy link
Contributor

@ben-kaufman ben-kaufman commented Dec 29, 2025

This PR adds support for migrating an existing React Native Bitkit into the Bitkit native app.
The migration passes:

Balances
Channels
Activities
Settings
Widgets
Tags and notes
Closed Channels

It also adds support for restoring a wallet created in RN app which was later deleted. Ie. create wallet in RN, use it, delete the app, install native, recover using mnemonic.

What's still needed:

New design for the loading screen and success toast of migration

@jvsena42 jvsena42 requested a review from Copilot December 29, 2025 17:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements migration support for transitioning users from the React Native Bitkit app to the native Android version. The migration preserves critical wallet data including balances, channels, activities, settings, widgets, and tags/notes while maintaining a recovery path if issues occur.

Key changes:

  • Adds comprehensive RN data migration logic handling MMKV storage, keychain data, and LDK channel state
  • Implements migration loading UI with timeout protection and error handling
  • Coordinates migration flow across wallet initialization, node startup, and data synchronization phases

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
gradle/libs.versions.toml Updates ldk-node-android dependency to v0.7.0-rc.2
app/build.gradle.kts Bumps version code from 17 to 160
MigrationService.kt Core migration service handling RN data extraction, decryption, and native app data transformation
MmkvParser.kt Binary parser for React Native MMKV storage format
MigrationLoadingScreen.kt Loading screen UI displayed during migration process
WalletViewModel.kt Orchestrates migration check and execution during wallet initialization
AppViewModel.kt Handles migration completion, sync coordination, and timeout management
MainActivity.kt Integrates migration loading screen into app navigation flow
LightningService.kt Adds channel migration support to LDK node setup
LightningRepo.kt Extends node start/setup to accept channel migration data and adds restart capability
CoreService.kt Adds method to mark all unseen activities as seen during migration
ActivityRepo.kt Exposes payment sync and bulk activity marking methods for migration

@jvsena42
Copy link
Member

jvsena42 commented Dec 31, 2025

Failed restoring the channels on local migration, I'll try again, just in case

Native data

Build variant: mainDebug

versionCode = 162
        create("mainnet") {
            dimension = "network"
            applicationIdSuffix = ""
            buildConfigField("String", "NETWORK", "\"REGTEST\"")
            resValue("string", "app_name", "Bitkit")
            manifestPlaceholders["app_icon"] = "@mipmap/ic_launcher_orange"
            manifestPlaceholders["app_icon_round"] = "@mipmap/ic_launcher_orange_round"
        }

RN data
versionCode = 161
network = regtest

logs.txt

@jvsena42
Copy link
Member

Failed restoring the channels on local migration, I'll try again, just in case

Native data

Build variant: mainDebug

versionCode = 162
       create("mainnet") {
           dimension = "network"
           applicationIdSuffix = ""
           buildConfigField("String", "NETWORK", "\"REGTEST\"")
           resValue("string", "app_name", "Bitkit")
           manifestPlaceholders["app_icon"] = "@mipmap/ic_launcher_orange"
           manifestPlaceholders["app_icon_round"] = "@mipmap/ic_launcher_orange_round"
       }

RN data versionCode = 161 network = regtest

logs.txt

Second attempt, still failed. also noticed that the PIN was not imported

@jvsena42
Copy link
Member

jvsena42 commented Dec 31, 2025

Tested:

On RN

  1. Create a fresh wallet
  2. Open a channel
  3. Send and receive lightning
  4. Open a second channel
  5. Enable PIN

On Android

  1. Install the app with the RN installed
  2. Migration triggered ✅
  3. Channels restored ✅
  4. Activities and balance restored ✅
  5. Pin restored ✅
  6. Disabled and re-enabled pin ✅

From the warnings, the PR needs a cleanup. After that I'll do a last review

@piotr-iohk
Copy link
Collaborator

In CI the @lightning_1 test fails. It passes for me locally. On CI however, I see that the failure is due to bg payments timesheet appearing after wallet restore from mnemonics (which is a step during the test). The BG payments timesheet appears despite the test hits "Allow" on the alert "Allow Bitkit Regtest to send you notification" (according to this conversation #556 (comment) the bg payments should not appear in such a case) cc: @jvsena42

Not sure, but maybe #565 will fix it?

lightning_-_Lightning_lightning_1_-_Can_receive_and_send_LN_payments-2026-01-01T13-14-46-568Z.mp4

@jvsena42
Copy link
Member

jvsena42 commented Jan 1, 2026

Not sure, but maybe #565 will fix it?

Probably. It has some improvements in this logic

@jvsena42
Copy link
Member

jvsena42 commented Jan 2, 2026

Can I review it already?

@ben-kaufman
Copy link
Contributor Author

Yes should be ready

@jvsena42
Copy link
Member

jvsena42 commented Jan 5, 2026

@ben-kaufman the pull from master should fix the E2E errors

@jvsena42
Copy link
Member

jvsena42 commented Jan 6, 2026

@ben-kaufman can I test it again?

@ben-kaufman
Copy link
Contributor Author

Yes 👍

Copy link
Member

@jvsena42 jvsena42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Created RN wallet with passphrase
  2. Opened channel and did LN operations
  3. Deleted the app
  4. Installed the native
  5. Recover the app
  6. LN data was not recovered ❌

I send the logs in DM

@ben-kaufman
Copy link
Contributor Author

Recover of LN channels should be fixed now

@ovitrif ovitrif requested a review from jvsena42 January 6, 2026 20:12
Copy link
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved with 2 nits, which I would like to defer to post-merge.

📋 Aside from these code-related remarks the other thing we discussed in DMs about migrating over the list of hidden todos from RN into the removedSuggestions list is the only comment I could add.

👏🏻 Everything else looks good to me, I like that most of the code is contained, given one day we will have to remove all of this, when we have enough indications that no more users need to migrate.

🧪 Tested by building the mainnet apk with the store release key and installing the APK over the PROD RN app which had a rather new wallet with most settings altered and 2 LN channels.

🟢 Everything migrated flawless and I was able to continue making and receiving payments to the 2 channels that persisted their open state.

Great work! 🥇

val selectedPairs = priceJson["selectedPairs"]?.jsonArray?.mapNotNull { pairElement ->
val pairStr = pairElement.jsonPrimitive.content.replace("_", "/")
when (pairStr) {
"BTC/USD" -> to.bitkit.data.dto.price.TradingPair.BTC_USD
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I guess we could go through all to.bitkit.*.* entries in Android Studio and CMD + ENTER on macOS → "add import for…" but it's highly unlikely we will end up spending much time maintaining this code so I'm fine with the way it is now too.

Android Studio


return runCatching {
val keysManager = KeysManager.of(bip32Seed, seconds, nanoSeconds)
val method = keysManager.javaClass.getMethod("get_node_secret_key")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: investigating if there's a non-reflective alternative to handle this, meanwhile we can merge this PR.

Copy link
Collaborator

@ovitrif ovitrif Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found a way in fa59e07

Will push it in a separate small PR which will include the cleanup for the other comment

@ovitrif ovitrif merged commit 306ee77 into master Jan 6, 2026
23 of 25 checks passed
@ovitrif ovitrif deleted the feat/rn-migration branch January 6, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants